package com.leet.meituan;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class EncodePassword {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        boolean b1 = false, b2 = false, e1=false, e2 = false;
        int n = Integer.parseInt(reader.readLine());
        String s = reader.readLine();
        char[] chars = s.toCharArray();
        int i = 0, j = chars.length-1;
        for(i = 0; i < chars.length; i++){
            if(chars[i] == 'M'){
                b1 = true;
            }
            if(b1 && chars[i] == 'T'){
                break;
            }
        }
        for(j = chars.length-1; j >= i; j--){
            if(chars[j] == 'T'){
                e1 = true;
            }
            if(e1 && chars[j] == 'M'){
                break;
            }
        }
        System.out.println(s.substring(i+1,j));
        reader.close();
    }
}
